PROJDIRS := .

SRCFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.s")
OBJFILES := $(patsubst %.s,%.o,$(SRCFILES))
ALLFILES := $(SRCFILES)

LD := x86_64-pc-linux-ld -T linkLoader.ld
NASM := nasm -f elf32

.PHONY: all clean todolist

all: loader.elf

    loader.elf: $(OBJFILES) linkLoader.ld
			@$(LD) -o loader.elf $?

    clean:
			-@cp loader.elf loader.elf.old
			-@$(RM) $(wildcard $(OBJFILES) $(DEPFILES) loader.elf)


todolist:
			-@for file in $(ALLFILES); do fgrep -H -e TODO -e FIXME $$file; done; true


 %.o: %.s Makefile
			@$(NASM) -o $@ $<